home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / database / clippc / clip_c.doc < prev    next >
Text File  |  1988-03-03  |  2KB  |  55 lines

  1. Overview:
  2.  
  3.    The function AlphaN is a good example of a Clipper UDF written in C. It
  4.    also shows how to use _exmgrab and _exmback, the EXTEND system's memory
  5.    allocation routines.
  6.  
  7.    Included is my version of EXTEND.H and NANDEF.H, CLIP_C.H, I hope
  8.    Nantucket doesn't mind. (Note to Nantucket: CLIP_C.H is a modified
  9.    version of your EXTEND.H and NANDEF.H, if you would like to use
  10.    any or all of my modifications, feel free.)
  11.  
  12.    Initially, I wrote AlphaN in dbase (AlphN.prg).  Then I rewrote it in C
  13.    (AlphN.c).  For a C compiler, I used Turbo C (tm), v 1.5 from Borland,
  14.    though I suspect others will work too (?).  Also, you shouldn't have any
  15.    difficulties using Turbo C 1.0.  For a dbase compiler, I used Clipper
  16.    (tm), Summer '87 from Nantucket.
  17.  
  18. Extend's memory allocation: _exmgrab and _exmback
  19.  
  20.    These two functions are a much appreciated addition to Clipper's
  21.    EXTEND system.  They are similar to the malloc and free functions
  22.    in C, which cannot be used in a Clipper UDF.
  23.  
  24.    You need to be aware of two things to use these functions successfully:
  25.       1) any memory _exmgrab.ed must be _exmback.ed in the same UDF
  26.       2) you must be sure to pass the correct size when _exmback.ing (free
  27.          doesn't require this)
  28.  
  29.    At first glance, these two functions may seem useless; i.e., it would
  30.    appear that you couldn't pass a string back to Clipper since you can't
  31.    keep the memory allocated.  However, the _retxx takes care of this by
  32.    allocating its own memory and copying the string into it.  You take
  33.    the following steps to return a string:
  34.       1) _exmgrab memory
  35.       2) construct string
  36.       3) _retxx it
  37.       4) _exmback memory
  38.  
  39.  
  40. Compilation of C UDF
  41.  
  42.    AlphN.c was compiled using the command line version of Turbo C with
  43.    the configuration file TURBOC.CFG available in the current directory.
  44.    This configuration file sets up TC to compile in large model and
  45.    forces the segment names to Clipper segment names and some other
  46.    stuff (see EXTEND.DOC on your Clipper disks)
  47.  
  48.  
  49. Questions, comments, suggestions.
  50.  
  51.    Please send any Q,C or S to:
  52.  
  53.    Mark Pfeifer
  54.    Source ID: BFB511
  55.    Compuserve: 73657,3203